﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NFine.Application.Biz;
using NFine.Code;

namespace NFine.Web.Areas.MemberManage.Controllers
{
    public class MemberBonusDetailController : ControllerBase
    {

        private MemberBonusApp memberBonusApp = new MemberBonusApp();

        //
        // GET: /MemberManage/MemberBonusDetail/

        public override ActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pagination"></param>
        /// <param name="OrderTimeStart"></param>
        /// <param name="OrderTimeEnd"></param>
        /// <returns></returns>
        [HttpGet]
        [HandlerAjaxOnly]
        [HandlerLogin]
        public ActionResult GetListForBonus(Pagination pagination,int BonusType, string OrderTimeStart, string OrderTimeEnd)
        {
            //TODO 通过session获取会员id，如果为空则默认是管理员登录获取所有记录
            //string memberId = ""
            var u = OperatorProvider.Provider.GetCurrent();
            string memberId = "";
            if (u != null && !u.IsSystem)
            {
                memberId = u.UserId;
            }

            var data = new
            {
                rows =
                memberBonusApp.GetListForBonus(pagination, memberId, BonusType, OrderTimeStart, OrderTimeEnd),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }

    }
}
